package com.gxc.config;

import com.gxc.job.MyFirstJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author GongXincheng
 * @since 2019-08-23 16:00
 */
//@Configuration
public class SchedulerConfigBean {

    @Bean
    public JobDetail sampleJobDetail() {
        return JobBuilder.newJob(MyFirstJob.class)
                .withIdentity("myFirstJob")
                .usingJobData("name", "World")
                .storeDurably()
                .build();
    }


    @Bean
    public Trigger sampleJobTrigger() {
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(2).repeatForever();

        return TriggerBuilder.newTrigger()
                .forJob(sampleJobDetail())
                .withIdentity("myTrigger")
                .withSchedule(scheduleBuilder)
                .build();
    }





}
